package net.chenlin.dp.modules.sys.controller;

import java.util.Arrays;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import net.chenlin.dp.common.entity.Result;
import net.chenlin.dp.common.utils.ShiroUtils;
import net.chenlin.dp.modules.sys.entity.SysMenuEntity;

/**
 * 系统菜单controller
 *
 * @author ZhouChenglin
 * @email yczclcn@163.com
 * @url www.chenlintech.com
 * @date 2017年8月10日 上午12:23:44
 */
@RestController
@RequestMapping("/sys/menu")
public class SysMenuController extends AbstractController {

	/**
	 * 用户菜单
	 * 
	 * @return
	 */
	@RequestMapping("/user")
	public Result user() {

		SysMenuEntity me = new SysMenuEntity();
		me.setMenuId(1L);
		me.setParentId(0L);
		me.setName("系统管理");
		me.setType(0);
		me.setIcon("fa fa-coffee");

		SysMenuEntity sub_me = new SysMenuEntity();
		sub_me.setMenuId(12L);
		sub_me.setParentId(1L);
		sub_me.setName("百度搜索");
		sub_me.setUrl("http://baidu.com");
		sub_me.setType(1);
		sub_me.setIcon("fa fa-th-list");

		SysMenuEntity sub_me2 = new SysMenuEntity();
		sub_me2.setMenuId(13L);
		sub_me2.setParentId(1L);
		sub_me2.setName("京东超市");
		sub_me2.setUrl("http://jd.com");
		sub_me2.setType(1);
		sub_me2.setIcon("fa fa-th-list");

		me.setList(Arrays.asList(new SysMenuEntity[] { sub_me, sub_me2 }));
		
		ShiroUtils.getSubject().checkPermissions("admin:sys:user");
		System.out.println("触发权限验证---");
		

		return Result.ok().put("menuList", Arrays.asList(new SysMenuEntity[] { me }));
	}

}
